<include file="Public/head" />
<script type="text/javascript" src="/static/js/jquery.form.js"></script>
<style type="text/css">
    .focus-btn{width:80px;border-radius: 3px;color: #fff;margin-left: 7px;padding: 0;background-color: #20ab4f;border: medium none;}
    .carousel table tr td{height:40px;line-height:40px;text-align:left;}
    .carousel_sub input{ background: #20ab4f none repeat scroll 0 0; border: 1px solid #20ab4f;border-radius: 3px;color: #fff;cursor: pointer;
                         font-size: 14px;height: 30px;line-height: 30px;margin: 30px 10px;text-align: center;width: 170px;}
    .add_page,.confirm_page{border:1px solid #ececec;}
    #driver{
         -moz-appearance: none;background: rgba(0, 0, 0, 0) url("http://img2.isou365.cn/paimai/yunying/images/sanjiao.jpg") no-repeat scroll 130px 5px;border: 1px solid #d7d7d7;color: #666;float: left;
    font-family: "微软雅黑";font-size: 12px;height: 26px;line-height: 26px;margin: 0 10px 10px 0;text-align: left;width: 154px;
    }
    #sort_id{
         -moz-appearance: none;background: rgba(0, 0, 0, 0) url("http://img2.isou365.cn/paimai/yunying/images/sanjiao.jpg") no-repeat scroll 130px 5px;border: 1px solid #d7d7d7;color: #666;float: left;
    font-family: "微软雅黑";font-size: 12px;height: 26px;line-height: 26px;margin: 0 10px 10px 0;text-align: left;width: 154px;
    }
    #force{
         -moz-appearance: none;background: rgba(0, 0, 0, 0) url("http://img2.isou365.cn/paimai/yunying/images/sanjiao.jpg") no-repeat scroll 130px 5px;border: 1px solid #d7d7d7;color: #666;float: left;
    font-family: "微软雅黑";font-size: 12px;height: 26px;line-height: 26px;margin: 0 10px 10px 0;text-align: left;width: 154px;
    }
</style>
</head>
<include file="Public/common_header" />
<div class="mian">
    <include file="Public/sidebar"  menu="xtgl.yygl" />

    <div class="mianR">
        <div class="add_page">
            <h3 class="cha">修改app应用</h3>
            <div class='carousel'>
            <form id="edit_app" action='/AppPublish/edit_post' enctype='multipart/form-data' method='post'>
                <input type="hidden" name='app_id' value="{$one_client_app.id}">
                <table width="100%">
                    <tr style="height:82px;">
                        <td width="10%" style="text-align:center">应用上传</td>
                        <td width="80%" style="padding:5px 10px;">
                        <input type="file" name="apppackage">{$one_client_app.link}
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:center">应用分类</td>
                        <td style="padding:5px 10px;">
                            <select name="sort_id" id="sort_id">
                                <option value="">请选择应用分类</option>
                                <?php foreach ($sort_id as $key => $value): ?>
                                    <option value="{$key}" 
                                    <?php if ($key == $one_client_app['sort_id']): ?>
                                        selected = "selected"
                                    <?php endif ?>>{$value}</option>
                                <?php endforeach ?>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:center">应用设备</td>
                        <td style="padding:5px 10px;">
                        <select name="driver" id="driver">
                            <option value="">请选择应用设备</option>
                            <?php foreach ($driver as $k => $v): ?>
                                <option value="{$k}" <?php if ($k == $one_client_app['driver']): ?>
                                        selected = "selected"
                                    <?php endif ?>>{$v}</option>
                            <?php endforeach ?>
                        </select>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:center">应用名称</td>
                        <td style="padding:5px 10px;">
                            <input type="text" name="appname" placeholder="请应用名称" style="width:300px;height:30px;line-height:30px;border:1px solid #ededee;padding-left:5px;" value="{$one_client_app.name}">
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:center">应用版本</td>
                        <td style="padding:5px 10px;">
                            <input type="text" name="version" placeholder="请输入版本" style="width:300px;height:30px;line-height:30px;border:1px solid #ededee;padding-left:5px;" value="{$one_client_app.version}">
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:center">应用备注</td>
                        <td style="padding:5px 10px;">
                            <input type="text" name="remark" placeholder="非必填项" style="width:300px;height:30px;line-height:30px;border:1px solid #ededee;padding-left:5px;" value="{$one_client_app.note}">
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:center">是否强制更新</td>
                        <td style="padding:5px 10px;">
                        <select name="force" id="force">
                            <option value="0" <?php if (0 == $one_client_app['force']): ?>
                                        selected = "selected"
                                    <?php endif ?>>否</option>
                            <option value="1" <?php if (1 == $one_client_app['force']): ?>
                                        selected = "selected"
                                    <?php endif ?>>是</option>
                        </select>
                        </td>
                    </tr>
                </table>
            </form>
                <div class='carousel_sub'>
                    <input type="button" value="确定" name="submit" id="submit">
                    <input type="button" value="取消" name="cancel">
                </div>
            </div>
            <div class="yunBei" style="z-index:999998"></div>
        </div>
    </div>
    <div class="clear"></div>
</div>

<script type="text/javascript">
    /**
     * 确定添加提交
     */
    $("input[name='submit']").click(function () {
        apppackage = $("input[name='apppackage']").val();
        sort_id = $("#sort_id").val();
        if (sort_id == '') {
            shibai_alert("请选择应用分类");
            return false;
        }
        driver = $("#driver").val();
        if (driver == '') {
            shibai_alert("请选择应用设备");
            return false;
        }
        appname = $("input[name='appname']").val();
        if (appname == '') {
            shibai_alert("请填写应用名称");
            return false;
        }
        version = $("input[name='version']").val();
        if (appname == '') {
            shibai_alert("请填写应用版本");
            return false;
        }
        remark = $("input[name='remark']").val();
        // params = {
        //     "sort_id": sort_id,
        //     "driver": driver,
        //     "appname":appname,
        //     "version": version,
        //     "sort": sort,
        //     "remark": remark
        // };
        $("#edit_app").ajaxSubmit({
            dataType:  'json',
            beforeSend: function() {
                $("#submit").val("提交中...").attr("disabled", 'disabled');
            },
            success: function(data) {
                if (data.code == 200) {
                    btn_alert(data.msg);
                    setTimeout(function () {
                        $("#submit").val("确定").removeAttr("disabled style");
                        window.location.href = "/AppPublish/index";
                    }, 2000);
                }else{
                    $("#submit").val("确定").removeAttr("disabled style");
                    shibai_alert(data.msg,2000);
                }
            },
            error:function(xhr){
                $("#submit").val("确定").removeAttr("disabled style");
                shibai_alert(xhr.responseText,2000);
            },
            // clearForm: true
        });
        // $.post("/AppPublish/add_post", params, function (res) {
        //     if (res.code == 200) {
        //         btn_alert(res.msg);
        //         setTimeout(function () {
        //             window.location.href = "/AppPublish/index";
        //         }, 2000);
        //     } else {
        //         shibai_alert(res.msg);
        //     }
        // }, 'json');
    });
    /**
     * 取消添加
     */
    $("input[name='cancel']").click(function () {
//        window.location.href = "/Carousel/index";
        window.history.back();
    });
</script>

<include file="Public/foot" />
